package com.utc.teamcenter.common.app.dialog.bean;

import javax.swing.JComponent;
import javax.swing.JScrollPane;

import com.teamcenter.rac.util.iTextArea;
import com.utc.teamcenter.common.util.TCUtil;

public class BeanITextArea extends BeanComponent {

	private iTextArea area;

	private JScrollPane scrollPane;

	public BeanITextArea(String key, String name, String value, boolean required) {
		this(key, name, value, required, 3, DEFAULT_LENGTH + 2, TCUtil
				.getDefaultMaxNameSize());
	}

	public BeanITextArea(String key, String name, String value,
			boolean required, int line, int length, int limit) {
		super(key, name);

		this.area = new iTextArea(TCUtil.createFilterDocument(), value, line,
				length, limit, false, null);

		this.area.setName(key);
		this.area.setLineWrap(true);
		this.area.setWrapStyleWord(true);
		this.scrollPane = new JScrollPane(this.area);
		this.area.setText(value);

	}

	public BeanITextArea(String key, String name, boolean required,
			iTextArea area) {
		super(key, name);

		this.area = area;
		setRequired(required);
	}

	@Override
	public void clear() {
		this.area.setText("");
	}

	@Override
	public JComponent getComponent() {
		return this.scrollPane;
	}

	@Override
	public String getText() {
		return this.area.getText();
	}

	@Override
	public boolean isRequired() {
		return this.area.isRequired();
	}

	@Override
	public void setText(String text) {
		this.area.setText(text);
	}

	@Override
	public void setRequired(boolean required) {
		this.area.setRequired(required);
	}

	@Override
	public void requestFocus() {
		this.area.requestFocus();
	}

	@Override
	public void setEnabled(boolean bool) {
		this.area.setEnabled(bool);
	}

	@Override
	public void setVisible(boolean bool) {
		this.area.setVisible(bool);
	}

}
